feat(java): conditional workflow steps#332
Conversation
Run a step only when its condition holds: on_success/on_failure/always or a callable predicate over the run's results. The tracker evaluates every successor on each outcome, running on-failure recovery branches and skip-cascading the rest, replacing the blanket fail-fast cascade.
on_failure recovery, on_success skip, always, and callable conditions.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughAdds conditional workflow step execution with selector-based and callable predicates. New public workflow context and condition types are wired through step modeling, submission serialization, tracker evaluation, and integration tests. ChangesWorkflow Conditional Execution
Sequence Diagram(s)sequenceDiagram
participant WorkflowTracker
participant shouldRun
participant callableCondition
participant WorkflowContext
WorkflowTracker->>shouldRun: evaluate successor condition
shouldRun->>callableCondition: resolve callable predicate
callableCondition->>WorkflowContext: buildContext(results, statuses, counts)
WorkflowContext-->>shouldRun: context
shouldRun-->>WorkflowTracker: run, skip, or defer
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@sdks/java/src/main/java/org/byteveda/taskito/DefaultTaskito.java`:
- Around line 401-408: The deferred-node detection in deferredNodes() is
treating explicit on_success branches like runtime-evaluated conditions, which
causes default/static paths to be deferred and later depend on WorkflowTracker
and trackWorkflows(...) for job creation. Update the logic so on_success is
normalized back to the default path and excluded from deferred handling, while
keeping fanOut, fanIn, gate, and true conditional branches deferred as before.
Also review the related branch handling around getWorkflowPlan so explicit
on_success does not inherit deferred-job enqueue behavior or queue assumptions.
In `@sdks/java/src/main/java/org/byteveda/taskito/workflows/Step.java`:
- Around line 136-170: Builder.condition(String) currently accepts arbitrary
strings, but WorkflowTracker.shouldRun(...) only understands specific values, so
typos silently fall back to on_success behavior. Update
Step.Builder.condition(String) to validate the input and reject any unknown
condition by throwing an error, while still allowing the known values used by
onSuccess(), onFailure(), always(), and condition(Condition). Keep the fix
localized to the Builder methods so invalid condition strings fail fast instead
of being accepted.
In `@sdks/java/src/main/java/org/byteveda/taskito/workflows/WorkflowTracker.java`:
- Around line 121-126: The fan-out failure path in handleFanOutChild still uses
a blanket cascadeSkipPending(runId), which skips evaluating conditional
successors for the parent. Update handleFanOutChild to follow the same
successor-evaluation flow as onOutcome() by promoting successors through
promoteSuccessors(...) (or equivalent conditional handling) instead of blindly
skipping all pending nodes, so always() and onFailure() branches can still run
after a fan-out child failure.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 94808600-1868-4291-9f8d-4ce6f5be0741
📒 Files selected for processing (7)
sdks/java/src/main/java/org/byteveda/taskito/DefaultTaskito.javasdks/java/src/main/java/org/byteveda/taskito/workflows/Condition.javasdks/java/src/main/java/org/byteveda/taskito/workflows/PlanNode.javasdks/java/src/main/java/org/byteveda/taskito/workflows/Step.javasdks/java/src/main/java/org/byteveda/taskito/workflows/WorkflowContext.javasdks/java/src/main/java/org/byteveda/taskito/workflows/WorkflowTracker.javasdks/java/src/test/java/org/byteveda/taskito/WorkflowConditionTest.java
Second PR in the Java-SDK full-parity series (stacked on #331).
Changes
on_success(default),on_failure,always, or a callableConditionevaluated on the worker.promoteSuccessorswas reworked to run on both success and failure, evaluating each successor's condition (recovery steps run, others skip-cascade).Condition(functional) +WorkflowContext(completed-node results/statuses the predicate sees). Callable conditions are registered viatrackWorkflows(workflow).No new Rust core — condition plumbing shipped with the gates PR; this wires the tracker.
Tests
Conditional-step coverage added;
./gradlew buildgreen (Gradle 9.6.1, JDK 17/21/22 locally).Summary by CodeRabbit
New Features
Bug Fixes
Tests